package main

import (
	"fmt"
	"runtime"
	//"time"
)

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	runtime.GOMAXPROCS(1)
	c := make(chan bool, 10)
	for i := 0; i < 10; i++ {
		go Go(c, i)
	}

	//	for v := range c {
	//		s += v
	//		//fmt.Println("end:", v)
	//	}
	//time.Sleep(1 * time.Second)
	//fmt.Println(<-c)
	for i := 0; i < 10; i++ {
		fmt.Println(<-c)
	}
	//	for i := range c {
	//		fmt.Println(i)
	//	}

}

func Go(c chan bool, index int) {
	a := 1
	for i := 0; i < 1000000; i++ {
		a += i
	}
	fmt.Println(index, a)
	//if index == 9 {
	c <- true
	//}
}
